// pages/statepage/statepage.js
const http = require('../../utils/http.js'); //相对路径
//import{formatTime} from '../../utils/data.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageName: 1, //css下标判断
    infoList: [], //获取数组，
    PageNum: 1, //分页页码,
    appointment: 1 //状态
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.getData(this.data.appointment)
  },
  statepitem(e) {
    let newdata = e.currentTarget.dataset['index'];
    wx.navigateTo({
      //传参预留
      url: '/pages/statepage/statepage/statitem?'
    });
  },
  navbind(e) {
    let index = e.currentTarget.dataset.index;
    this.setData({
      //初始化数据，判断
      pageName: index,
      PageNum: 1,
      infoList: [],
      appointment: index
    })
    this.getData(this.data.appointment) // 查询方法  
  },
  getData(appointment = 1) {
    http.postRequest('/mini/v1/appointment/order_list', {
      appointment_status: appointment,
      per_page: 10,
      page: 1
    }, res => {
      let { data } = res.data;
      console.log(res)
      this.setData({
        infoList: data
      })
    })
  }
})